﻿<UserControl x:Class="BetterExplorer.PieChart.PiePlotter"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:b="clr-namespace:BetterExplorer.PieChart"
    xmlns:p="clr-namespace:BetterExplorer.PieChart"
    xmlns:util="clr-namespace:BetterExplorer.PieChart">
    <UserControl.Resources>
        <util:FormattingConverter x:Key="formatter" />
        <util:FileSizeConverter x:Key="fsConverter"/>
        <Style TargetType="{x:Type b:PiePiece}">
            <Setter Property="Stroke" Value="White"/>
            <Setter Property="StrokeThickness" Value="1"/>
        </Style>

        <Style TargetType="{x:Type ToolTip}">
            <Setter Property="Opacity" Value=".95" />
            <Setter Property="Template">
                <Setter.Value>
                    <!-- modify the tooltip control template to add a drop shadow-->
                    <ControlTemplate TargetType="{x:Type ToolTip}">
                        <Grid Background="Transparent" Margin="5" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">                            
                            <Rectangle Fill="White" Height="{TemplateBinding Height}" RadiusX="7.5" RadiusY="7.5">
                                <Rectangle.BitmapEffect>
                                    <DropShadowBitmapEffect ShadowDepth="3"/>
                                </Rectangle.BitmapEffect>
                            </Rectangle>
                            <ContentPresenter Margin="5"  HorizontalAlignment="Center" VerticalAlignment="Center" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <!-- bind the stack panel datacontext to the tooltip data context -->
                        <StackPanel Orientation="Horizontal"
                                DataContext="{Binding Path=DataContext, RelativeSource={RelativeSource AncestorType={x:Type ToolTip}}}">
                            
                            <!-- navigate to the pie piece (which is the placement target of the tooltip) and obtain the percentage -->
                            <TextBlock FontSize="30" FontWeight="Bold" Margin="0,0,5,0"                        
                                    DataContext="{Binding Path=PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ToolTip}}}"
                                    Text="{Binding Path=Percentage, Converter={StaticResource formatter}, ConverterParameter='\{0:0%\}'}"/>
                    
                            <StackPanel Orientation="Vertical">
                                <TextBlock FontWeight="Bold"  Text="{Binding Path=FolderSizeLoc}"/>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="Size"/>                               
                                    <TextBlock Text=": "/>
                                    <TextBlock Text="{Binding Path=FSize,Converter={StaticResource fsConverter}}"/>
                                </StackPanel>
                                <!--StackPanel Orientation="Horizontal">
                                    <TextBlock Text="Benchmark"/>                               
                                    <TextBlock Text=": "/>
                                    <TextBlock Text="{Binding Path=Benchmark}"/>
                                </StackPanel-->
                            </StackPanel>
                        </StackPanel>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>


        <!-- http://forums.msdn.microsoft.com/en-US/wpf/thread/4fbf876e-15a9-4581-badc-0277d873366a -->
        <!-- http://blogs.msdn.com/tom_mathews/archive/2006/11/06/binding-a-tooltip-in-xaml.aspx -->
        <!-- http://joshsmithonwpf.wordpress.com/2008/07/22/enable-elementname-bindings-with-elementspy/ -->
       
        
    </UserControl.Resources>
    <Grid>
        <Canvas Name="canvas" VerticalAlignment="Top" />
    </Grid>

</UserControl>

    